﻿using System;

class CatalanNumbers
{
    static void Main()
    {
        //In the combinatorial mathematics, the Catalan numbers are calculated by the following formula: ...
        //Write a program to calculate the Nth Catalan number by given N.

        Console.Write("N = ");
        int n = int.Parse(Console.ReadLine());
        int factorial = 1;
        int nPlusOneFactorial = 1;
        int nFactorial = 1;
        int catalan = 1;

        if (n >= 1)
        {
            for (int i = 1; i <= 2 * n; i++)
            {
                factorial = factorial * i;
            }
            for (int j = 1; j <= n + 1; j++)
            {
                nPlusOneFactorial = nPlusOneFactorial * j;
            }
            for (int k = 1; k <= n; k++)
            {
                nFactorial = nFactorial * k;
            }
            catalan = factorial / (nFactorial * nPlusOneFactorial);
            Console.WriteLine("Catalan`s numbers = " + catalan);
        }
        else if (n == 0)
        {
            Console.WriteLine("Catalan`s numbers = " + catalan);
        }
    }
}

